package pta.newch04.ex24;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Circle c1 = new Circle();
        System.out.println(c1);
        System.out.println("c1:area=" + c1.getArea());
        Circle c2 = new Circle();
        System.out.println(c2);
        int radius1 = scanner.nextInt();
        c2.setRadius(radius1);
        System.out.println(c2);
        System.out.println("c2:area=" + c2.getArea());
        int radius2 = scanner.nextInt();
        Circle c3 = new Circle(radius2);
        System.out.println(c3);
        System.out.println("c3:area=" + c3.getArea());
        scanner.close();
    }
}

class  Circle{


    public Circle(int radius) {
        if(radius <= 0){
            this.radius = 2;
        } else {
            this.radius = radius;
        }
        System.out.println("this is a constructor with para");
    }

    public Circle(){
        this.radius = 2;
        System.out.println("this is a constructor");
    }
    public int getRadius() {
        return radius;
    }

    public void setRadius(int radius) {
        if(radius <= 0){
            this.radius = 2;
        } else {
            this.radius = radius;
        }
    }

    public int getArea() {
        return(int) (Math.PI * radius * radius);
    }

    @Override
    public String toString() {
        return "Circle [radius=" + radius + "]";
    }

    private int radius;
}